﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Ny.Ci.EntityFrameworkCore.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AttachmentInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Title = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: false),
                    Path = table.Column<string>(nullable: false),
                    PathEx = table.Column<string>(nullable: true),
                    Size = table.Column<string>(nullable: true),
                    SubjectId = table.Column<Guid>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AttachmentInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HotspotPic",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Title = table.Column<string>(nullable: false),
                    Identification = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotspotPic", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MentionType",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: false),
                    DepartmentId = table.Column<int>(nullable: true),
                    DepartmentName = table.Column<string>(nullable: true),
                    CreateUserId = table.Column<int>(nullable: false),
                    CreateUserName = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MentionType", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PointsLevel",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    LevelName = table.Column<string>(nullable: false),
                    Icon = table.Column<string>(nullable: true),
                    Point = table.Column<int>(nullable: false),
                    CreateUserId = table.Column<int>(nullable: false),
                    CreateUserName = table.Column<int>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PointsLevel", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PointsRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Point = table.Column<int>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    UserID = table.Column<int>(nullable: false),
                    UserName = table.Column<int>(nullable: false),
                    Memo = table.Column<string>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PointsRecord", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserPoints",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    PointAll = table.Column<int>(nullable: false),
                    PointCurrent = table.Column<int>(nullable: false),
                    UserID = table.Column<int>(nullable: false),
                    UserName = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserPoints", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MentionInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Integral = table.Column<int>(nullable: false),
                    OccurTime = table.Column<DateTime>(nullable: true),
                    OccurPlace = table.Column<string>(nullable: true),
                    IsAnonymous = table.Column<bool>(nullable: false),
                    MentionTypeId = table.Column<Guid>(nullable: false),
                    Status = table.Column<int>(nullable: false),
                    CreateUserId = table.Column<int>(nullable: false),
                    CreateUserName = table.Column<int>(nullable: false),
                    Entrance = table.Column<int>(nullable: false),
                    Content = table.Column<string>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MentionInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MentionInfo_MentionType_MentionTypeId",
                        column: x => x.MentionTypeId,
                        principalTable: "MentionType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Suggestion",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Title = table.Column<string>(nullable: false),
                    Content = table.Column<string>(nullable: false),
                    IsImportant = table.Column<bool>(nullable: true),
                    MentionTypeId = table.Column<Guid>(nullable: false),
                    Result = table.Column<string>(nullable: true),
                    DepartmentId = table.Column<int>(nullable: true),
                    DepartmentName = table.Column<string>(nullable: true),
                    ProposeUserId = table.Column<int>(nullable: false),
                    ProposeUserName = table.Column<int>(nullable: false),
                    CreateUserName = table.Column<int>(nullable: false),
                    CreateUserId = table.Column<int>(nullable: false),
                    Entrance = table.Column<int>(nullable: false),
                    Statue = table.Column<int>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Suggestion", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Suggestion_MentionType_MentionTypeId",
                        column: x => x.MentionTypeId,
                        principalTable: "MentionType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MentionOperLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Action = table.Column<int>(nullable: false),
                    Score = table.Column<int>(nullable: true),
                    HandleOpinion = table.Column<string>(nullable: true),
                    HandleTime = table.Column<DateTime>(nullable: true),
                    ReceiveTime = table.Column<DateTime>(nullable: false),
                    HandleUserId = table.Column<int>(nullable: false),
                    HandleUser = table.Column<string>(nullable: true),
                    MentionId = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MentionOperLog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MentionOperLog_MentionInfo_MentionId",
                        column: x => x.MentionId,
                        principalTable: "MentionInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "SuggestionOperLog",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Action = table.Column<int>(nullable: false),
                    Score = table.Column<int>(nullable: true),
                    HandleOpinion = table.Column<string>(nullable: true),
                    HandleTime = table.Column<DateTime>(nullable: true),
                    ReceiveTime = table.Column<DateTime>(nullable: false),
                    IsInDuty = table.Column<bool>(nullable: true),
                    HandleUserId = table.Column<int>(nullable: false),
                    HandleUser = table.Column<string>(nullable: true),
                    SuggestionId = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SuggestionOperLog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SuggestionOperLog_Suggestion_SuggestionId",
                        column: x => x.SuggestionId,
                        principalTable: "Suggestion",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TeamUserLink",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    UserId = table.Column<int>(nullable: false),
                    User = table.Column<string>(nullable: true),
                    SuggestionId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TeamUserLink", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TeamUserLink_Suggestion_SuggestionId",
                        column: x => x.SuggestionId,
                        principalTable: "Suggestion",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_MentionInfo_MentionTypeId",
                table: "MentionInfo",
                column: "MentionTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_MentionOperLog_MentionId",
                table: "MentionOperLog",
                column: "MentionId");

            migrationBuilder.CreateIndex(
                name: "IX_Suggestion_MentionTypeId",
                table: "Suggestion",
                column: "MentionTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_SuggestionOperLog_SuggestionId",
                table: "SuggestionOperLog",
                column: "SuggestionId");

            migrationBuilder.CreateIndex(
                name: "IX_TeamUserLink_SuggestionId",
                table: "TeamUserLink",
                column: "SuggestionId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AttachmentInfo");

            migrationBuilder.DropTable(
                name: "HotspotPic");

            migrationBuilder.DropTable(
                name: "MentionOperLog");

            migrationBuilder.DropTable(
                name: "PointsLevel");

            migrationBuilder.DropTable(
                name: "PointsRecord");

            migrationBuilder.DropTable(
                name: "SuggestionOperLog");

            migrationBuilder.DropTable(
                name: "TeamUserLink");

            migrationBuilder.DropTable(
                name: "UserPoints");

            migrationBuilder.DropTable(
                name: "MentionInfo");

            migrationBuilder.DropTable(
                name: "Suggestion");

            migrationBuilder.DropTable(
                name: "MentionType");
        }
    }
}
